package com.ktjy.config;

import com.ktjy.timing.QuartzTest;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(QuartzTest.class)
                .withIdentity("myJob")  // 设置任务名称
                .storeDurably()
                .build();   // 创建一个JobDetail
    }

    @Bean
    public Trigger trigger() {
        return TriggerBuilder.newTrigger()
                .withIdentity("myTrigger")  // 设置触发器名称
                .forJob(jobDetail())    // 设置任务
                .withSchedule(CronScheduleBuilder.cronSchedule("0/10 * * * * ?"))// 设置触发器时间
                .build();   // 创建一个Trigger
    }
}
